import { Column, Entity, Index, PrimaryGeneratedColumn } from "typeorm";

@Index("idx_channel_id", ["channelId"], {})
@Entity("rrz_channelfield", { schema: "rrzcms" })
export class RrzChannelfield {
  @PrimaryGeneratedColumn({
    type: "int",
    name: "id",
    comment: "自增ID",
    unsigned: true,
  })
  id: number;

  @Column("varchar", { name: "name", comment: "字段名称", length: 32 })
  name: string;

  @Column("int", {
    name: "channel_id",
    comment: "所属模型id",
    unsigned: true,
    default: () => "'0'",
  })
  channelId: number;

  @Column("enum", {
    name: "channel_type",
    comment: "类型（articles：文章，goods：产品）",
    enum: ["articles", "goods"],
    default: () => "'articles'",
  })
  channelType: "articles" | "goods";

  @Column("varchar", { name: "title", comment: "字段标题", length: 32 })
  title: string;

  @Column("varchar", { name: "dtype", comment: "字段类型", length: 32 })
  dtype: string;

  @Column("text", { name: "define", comment: "字段定义" })
  define: string;

  @Column("int", {
    name: "maxlength",
    comment: "最大长度，文本数据必须填写，大于255为text类型",
    unsigned: true,
    default: () => "'0'",
  })
  maxlength: number;

  @Column("longtext", { name: "dfvalue", nullable: true, comment: "默认值" })
  dfvalue: string | null;

  @Column("varchar", { name: "dfvalue_unit", comment: "数值单位", length: 50 })
  dfvalueUnit: string;

  @Column("varchar", { name: "remark", comment: "提示说明", length: 256 })
  remark: string;

  @Column("tinyint", {
    name: "is_filter",
    comment: "是否应用于条件筛选",
    unsigned: true,
    default: () => "'0'",
  })
  isFilter: number;

  @Column("tinyint", {
    name: "ifrequire",
    comment: "是否必填",
    unsigned: true,
    default: () => "'0'",
  })
  ifrequire: number;

  @Column("int", {
    name: "sort",
    comment: "排序",
    unsigned: true,
    default: () => "'100'",
  })
  sort: number;

  @Column("int", {
    name: "add_time",
    comment: "创建时间",
    unsigned: true,
    default: () => "'0'",
  })
  addTime: number;

  @Column("int", {
    name: "update_time",
    comment: "更新时间",
    unsigned: true,
    default: () => "'0'",
  })
  updateTime: number;
}
